package cn.ztuo.bitrade.dao;

import cn.ztuo.bitrade.entity.ContractPriceControl;
import cn.ztuo.bitrade.vo.contractPriceControlVo.ContractPriceControlAddReqVo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

public interface ContractPriceControlMapper extends JpaRepository<ContractPriceControl, String>, JpaSpecificationExecutor<ContractPriceControl>, QueryDslPredicateExecutor<ContractPriceControl> {

    ContractPriceControl getById(Long id);

    @Query("select count(c) FROM ContractPriceControl c where (?1 is null or c.id <> ?1) and c.symbol = ?2 and (?3 between c.startTime and c.endTime or ?4 between c.startTime and c.endTime) and ( c.status = 0 OR c.status = 1 OR c.status = 2 ) ")
    int counts(Long id,String symbol,Date startTime,Date endTime);

}
